// var arr = [312, 38, 44, 99,3,1,5345,234,6457,234,555,444,2,23];
// for (var j = 0; j <= (arr.length - 1) - 1; j++) {
//     for (var i = 0; i <= (arr.length - 1) - 1; i++) {
//         if (arr[i] > arr[i + 1]) {
//             var middle = 0;
//             middle = arr[i];
//             arr[i] = arr[i + 1];
//             arr[i + 1] = middle;
//         }
//     }
// }
// console.log(arr);
var arr = [34, 231, 23, 11, 22, 44, 33, 12];
for (var j = 0; j <= (arr.length - 1) - 1; j++) {
    var min = j; 
    for (var i = j + 1; i <= arr.length - 1; i++) {
        if (arr[min] > arr[i]) {
            min = i; 
        }
    }
    if (min != j) {
        var m = 0;
        m = arr[j];
        arr[j] = arr[min];
        arr[min] = m;
    }
}
console.log(arr);